# -*-conding:utf-8-*-

"""

 Created by feiwo at 2018/7/29
 
"""

from flask import Flask

__author__ = 'feiwo'


def create_app():
    app = Flask(__name__)
    app.config.from_object('app.conf.config')
    registerBlueprint(app)
    initDb(app)
    return app


def registerBlueprint(app):
    """
    注册蓝图
    :param app:
    :return:
    """
    from app.backend.BackendBP import BackendBP
    backend = BackendBP.instance()
    app.register_blueprint(backend)


def initDb(flaskApp):
    """
    初始化数据库
    :param flaskApp:
    :return:
    """
    from app.models.Base import db
    db.init_app(flaskApp)
    # db.create_all(app=flaskApp)